package org.xdq.可重入锁;

public class Test {
    public static void main(String[] args) {
        Object lock = new Object();

        new Thread(()->{
            synchronized (lock){
                System.out.println("第一次持有lock");
                synchronized (lock){
                    System.out.println("第二次持有lock");
                }

                System.out.println("第一次释放lock");
                try {
                    Thread.sleep(10000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println("第二次释放lock");
        }).start();



        new Thread(()->{

            System.out.println("等待lock");
            synchronized (lock){
                System.out.println("获得lock");

            }
        }).start();


    }
}
